from google.appengine.ext import db

class Config(db.Model):
    name        = db.StringProperty(required=False)
    value       = db.StringProperty(required=False, multiline=True)
    created     = db.DateTimeProperty(auto_now_add=True)
    modified    = db.DateTimeProperty(auto_now=True)

class VMember(db.Model):
    user          = db.UserProperty(auto_current_user_add=True)
    name          = db.StringProperty(required=False)
    image         = db.BlobProperty()  
    status        = db.IntegerProperty(default=1) #0: New , 1: Approve, 2: Cancel
    created       = db.DateTimeProperty(auto_now_add=True)
    visited       = db.DateTimeProperty(auto_now=True)
  
class VCate(db.Model):
    title       = db.StringProperty()
    status      = db.IntegerProperty(default=1) #0: hide #1: show
    parent_id   = db.IntegerProperty(default=0)
    member      = db.ReferenceProperty(VMember, collection_name='cate')
    
class VArticle(db.Model):
    title       = db.StringProperty()
    image       = db.BlobProperty()
    link        = db.LinkProperty()
    scontent    = db.StringProperty(multiline=True)
    content     = db.TextProperty()
    hit         = db.IntegerProperty(default=1)
    status      = db.IntegerProperty(default=1) #0: hide #1: show
    member      = db.ReferenceProperty(VMember, collection_name='articles')
    member_name = db.StringProperty()
    member_id   = db.IntegerProperty(default=0)
    cate        = db.ReferenceProperty(VCate, collection_name='articles')
    cate_id     = db.IntegerProperty(default=0)
    created     = db.DateTimeProperty(auto_now_add=True)

class VChat(db.Model):
    scontent    = db.TextProperty()
    status      = db.IntegerProperty(default=1) #0: hide #1: show
    member 		= db.ReferenceProperty(VMember, collection_name='chat')
    member_name = db.StringProperty()
    member_id	= db.IntegerProperty(default=0)
    member_id_to  = db.IntegerProperty(default=0)
    cate        = db.ReferenceProperty(VCate, collection_name='chat')
    cate_id     = db.IntegerProperty(default=0)
    article     = db.ReferenceProperty(VArticle, collection_name='chat')
    article_id  = db.IntegerProperty(default=0)
    created     = db.DateTimeProperty(auto_now_add=True)
  

